package entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by xuweijie on 2017/4/20.
 * 消费记录表实体
 */
@Entity
@Table(name = "cro_bills")
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@DynamicInsert(true)
public class CroBills implements Serializable {

    private String id;
    private CroCustomer croCustomer;
    private String billtype;
    private double consumption;
    private Date costDate;
    private String del_flag;



    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="costomId",referencedColumnName = "id")
    public CroCustomer getCroCustomer() {
        return croCustomer;
    }

    public void setCroCustomer(CroCustomer croCustomer) {
        this.croCustomer = croCustomer;
    }

    @Column(columnDefinition ="varchar(10) default '0'")
    public String getBilltype() {
        return billtype;
    }

    public void setBilltype(String billtype) {
        this.billtype = billtype;
    }

    public double getConsumption() {
        return consumption;
    }

    public void setConsumption(double consumption) {
        this.consumption = consumption;
    }

    @CreationTimestamp
    public Date getCostDate() {
        return costDate;
    }

    public void setCostDate(Date costDate) {
        this.costDate = costDate;
    }

    @Column(columnDefinition ="varchar(1) default '0'")
    public String getDel_flag() {
        return del_flag;
    }

    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }
}
